package sphere.view;

import java.awt.*;

import sphere.controller.SphereController;

public class SphereWindow extends Frame
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	Label rad, vol, surf;
	TextField texte, texte2, texte3;
	Panel panelPrinc;
	private final static String RADIUS = "Radius";
	private final static String VOLUME = "Volume";
	private final static String SURFACE = "Surface";
	private final String titre;
	private SphereController controller;

	public SphereWindow(SphereController c) throws HeadlessException
	{
		this.titre = "Calcul Sphère";
		this.controller = c;
		this.controller.setView(this);
		init();
	}

	public SphereWindow(String titre, SphereController c) throws HeadlessException
	{
		this.titre = titre;
		this.controller = c;
		this.controller.setView(this);
		init();
	}

	public void init()
	{

		this.setTitle(titre);
		addWindowListener(new MonWindowListner());
		setLayout(new FlowLayout(FlowLayout.CENTER));

		panelPrinc = new Panel();
		this.add(panelPrinc);
		panelPrinc.setLayout(new GridLayout(3, 2));

		rad = new Label(RADIUS);
		vol = new Label(VOLUME);
		surf = new Label(SURFACE);

		texte = new TextField(20);
		texte.addTextListener(controller);

		texte2 = new TextField(20);
		texte3 = new TextField(20);

		panelPrinc.add(rad);
		panelPrinc.add(texte);
		panelPrinc.add(vol);
		panelPrinc.add(texte2);
		panelPrinc.add(surf);
		panelPrinc.add(texte3);
		texte2.setEditable(false);
		texte3.setEditable(false);
		this.setVisible(true);
		this.setResizable(false);
		this.setSize(300, 150);
		this.pack();
	}
	
	public void setrayon(int rayon)
	{
		this.texte.setText(String.valueOf(rayon));
	}
	
	public void setSurface(double surface)
	{
		this.texte2.setText(String.valueOf(surface));
	}

	public void setVolume(double volume)
	{
		this.texte3.setText(String.valueOf(volume));
	}
}
